package com.haidechizi.designpattern.strategy.apply;

/**
 * @author haidechizi
 */
public class DefaultBarCodeAnalysis implements BarCodeAnalysis {
    /**
     * 解析条码
     *
     * @param itemCode
     * @return
     */
    @Override
    public BarCode analysis(String itemCode) {
        String type = itemCode.substring(0, 1);
        String code = itemCode.substring(1, 6);
        String price = itemCode.substring(6, 10);
        return new BarCode(Integer.parseInt(type), code, Integer.parseInt(price));
    }
}
